import os, sys
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from string import LinkString

def BF(cstr1, cstr2):
    s = LinkString()
    t = LinkString()
    s.StrAssign(cstr1)
    t.StrAssign(cstr2)

    s_p = s.head.next
    t_p = t.head.next
    cnt = 0 
    tmp_p = s_p

    while s_p != None and t_p != None:
        if s_p.data == t_p.data:
            s_p = s_p.next
            t_p = t_p.next
        else:
            t_p = t.head.next
            tmp_p = tmp_p.next
            s_p = tmp_p
            cnt += 1
    if t_p == None:
        return cnt
    else:
        return False

if __name__ == "__main__":
    cstr1 = "11aaaaas"
    cstr2 = "aaaa2a"
    print(BF(cstr1, cstr2))